home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 39 / Issue 39.iso / pc / PCSoftware / RoboHelp / DISK1 / DATA.1 / ShowWebHelp.java < prev    next >
Encoding:
Java Source  |  2000-06-26  |  22.3 KB  |  685 lines

  1. // eHelpÆ Corporation
  2. // Copyright© 1998-2000 eHelpÆ Corporation.All rights reserved.
  3. // ShowWebHelp.js
  4. // The Helper class for WebHelp Content Sensitive Help
  5.  
  6. package robohelp;
  7.  
  8. import netscape.javascript.*;
  9. import java.applet.Applet;
  10. import java.net.*;
  11. import java.io.File;
  12.  
  13.  
  14. public class ShowWebHelp
  15. {
  16.     public static  final int WOF_LOCATION        = 0x1;
  17.     public static  final int WOF_MENUBAR        = 0x2;
  18.     public static  final int WOF_RESIZABLE    = 0x4;
  19.     public static  final int WOF_TOOLBAR        = 0x8;
  20.     public static  final int WOF_STATUS        = 0x10;
  21.     public static  final int WOF_SCROLLBARS    = 0x20;
  22.     
  23.     public static  boolean context(String strURL, String strTopic, int left, int top, int width, int height, int flag, Applet applet) {
  24.         return context(strURL, strTopic, getOptionsString(left, top, width, height, flag), applet);
  25.     }
  26.     
  27.     public static  boolean context(String strURL, String strTopic, String strWindowOption, Applet applet) {
  28.         String strTemp = "";
  29.         int     posbegin = 0;
  30.         do {
  31.             int pos = strTopic.indexOf("://", posbegin);
  32.             if (pos != -1) {
  33.                 strTemp += strTopic.substring(posbegin, pos) + "%072%057%057";
  34.                 posbegin = pos + 3;
  35.             }
  36.             else {
  37.                 strTemp += strTopic.substring(posbegin);
  38.                 break;
  39.             }
  40.         } while (true);
  41.         strTopic = strTemp;
  42. //        strTopic = strTopic.replace('://', '%072%057%057');
  43.         String strURLWithTopic = strURL + "#" + strTopic;
  44.         boolean bJSAccessable = true;
  45.         URL url = null;
  46.         
  47.         if (System.getProperty("java.vendor").indexOf("Netscape") == -1 ) {// IE
  48.             try {
  49.                 String strURLWithWindowOption = strURLWithTopic + "," + strWindowOption;
  50.                 url =  makeURL(applet.getDocumentBase(),strURLWithWindowOption, strURLWithWindowOption);
  51.                 JSObject win = JSObject.getWindow(applet);   
  52.                 win.eval("window.open(\"" + url.toString() + "\", \"HelpSecondary\", \"left=2000,top=2000,height=1,width=1\");");
  53.                 return true;
  54.             }
  55.             catch (Exception e) {
  56.                 bJSAccessable = false;
  57.                 e.printStackTrace();
  58.             }
  59.             if (!bJSAccessable) {
  60.                 try {
  61.                     String strURLWithWindowOption = strURLWithTopic + "," + strWindowOption;
  62.                     url =  makeURL(applet.getDocumentBase(), strURLWithWindowOption, strURLWithWindowOption);
  63.                     System.out.println(url.toString());
  64.                     applet.getAppletContext().showDocument(url, "HelpSecondary");
  65.                     return true;
  66.                 }
  67.                 catch (Exception e) {
  68.                     e.printStackTrace();
  69.                 }
  70.             }
  71.             return false;
  72.         }
  73.         else { // netscape
  74.             try {
  75.                 url =  makeURL(applet.getDocumentBase(),strURLWithTopic, strURLWithTopic);
  76.                 JSObject win = JSObject.getWindow(applet);   
  77.                 win.eval("window.open(\"" + url.toString() + "\", \"HelpStub\", \"" + strWindowOption + "\");");
  78.                 return true;
  79.             }
  80.             catch (Exception e) {
  81.                 bJSAccessable = false;
  82.                 e.printStackTrace();
  83.             }
  84.             if (!bJSAccessable) {
  85.                 try {
  86.                     String strURLWithWindowOption = strURLWithTopic + "," + strWindowOption;
  87.                     url =  makeURL(applet.getDocumentBase(), strURLWithWindowOption, strURLWithWindowOption);
  88.                     applet.getAppletContext().showDocument(url, "HelpSecondary");
  89.                     return true;
  90.                 }
  91.                 catch (Exception e) {
  92.                     e.printStackTrace();
  93.                 }
  94.             }
  95.             return false;
  96.         }
  97.     }
  98.     
  99.     public static String getOptionsString(int left, int top, int width, int height, int flag)
  100.     {
  101.         String strWindowOptions = "";
  102.         strWindowOptions += "left=" + Integer.toString(left,10);
  103.         strWindowOptions += ",ScreenX=" + Integer.toString(left,10);
  104.         
  105.         strWindowOptions += ",top=" + Integer.toString(top,10);
  106.         strWindowOptions += ",ScreenY=" + Integer.toString(top,10);
  107.         
  108.         strWindowOptions += ",width=" + Integer.toString(width,10);
  109.         strWindowOptions += ",OuterWidth=" + Integer.toString(width,10);
  110.         
  111.         strWindowOptions += ",height=" + Integer.toString(height,10);
  112.         strWindowOptions += ",OuterHeight=" + Integer.toString(height,10);
  113.  
  114.         if ((flag & WOF_LOCATION) != 0) {
  115.             strWindowOptions += ",location=yes";
  116.         }
  117.         else {
  118.             strWindowOptions += ",location=no";
  119.         }
  120.             
  121.         if ((flag &WOF_MENUBAR) != 0) {
  122.             strWindowOptions += ",menubar=yes";
  123.         }
  124.         else {
  125.             strWindowOptions += ",menubar=no";
  126.         }
  127.         if ((flag &WOF_RESIZABLE) != 0) {
  128.             strWindowOptions += ",resizable=yes";
  129.         }
  130.         else {
  131.             strWindowOptions += ",resizable=no";
  132.         }
  133.         if ((flag &WOF_TOOLBAR) != 0) {
  134.             strWindowOptions += ",toolbar=yes";
  135.         }
  136.         else {
  137.             strWindowOptions += ",toolbar=no";
  138.         }
  139.         if ((flag &WOF_STATUS) != 0) {
  140.             strWindowOptions += ",status=yes";
  141.         }
  142.         else {
  143.             strWindowOptions += ",status=no";
  144.         }
  145.         if ((flag &WOF_SCROLLBARS) != 0) {
  146.             strWindowOptions += ",scrollbars=yes";
  147.         }
  148.         else {
  149.             strWindowOptions += ",scrollbars=no";
  150.         }
  151.         return strWindowOptions;
  152.     }
  153.     
  154.     // return a URL build from the local and url parameters
  155.     static URL makeURL (URL base, String local, String url) throws MalformedURLException
  156.     {
  157.         try {
  158.                 //return new URL (base, local);
  159.                 String protocol = base.getProtocol();
  160.                 String host        = base.getHost();
  161.                 String file        = base.getFile();
  162.                 int       port        = base.getPort();
  163.  
  164.                 String fileNew0 = tuHtmlToText(file);
  165.                 String fileNew1 = GetNormalizedLocal(fileNew0);
  166.                 String fileNew    = TruncURLtoQuestionMark(fileNew1);
  167.                 URL baseNew = new URL(protocol,host,port,fileNew);
  168.  
  169.                 String localNew0 = tuHtmlToText(local);
  170.                 String localNew = GetNormalizedLocal(localNew0);
  171.                 return new URL (baseNew, localNew);
  172.         }
  173.         catch (MalformedURLException x) {
  174.             x.printStackTrace();
  175.  
  176.             // no it isn't - but it might be
  177.             // a MS-type file spec (eg e:\temp\foo)
  178.             // so try opening it as a file
  179.             // god knows what this will do on
  180.             // a unix machine...
  181.  
  182.             File f = new File (local);
  183.             if (f.exists ()) {
  184.                 // OK - it's a local file, try appending
  185.                 // "file:/" onto it and opening it - even
  186.                 // though the slashes will be all funny
  187.                 // this seems to work!
  188.                 return new URL ("file:/" + local);
  189.             }
  190.             else {
  191.  
  192.                 // the file doesn't exist....
  193.                 // should display a dialog box here
  194.                 // and now try the secondary URL
  195.  
  196.                 return new URL (base, url);
  197.             }
  198.         }
  199.     }
  200.     
  201.     static String TruncURLtoQuestionMark(String str)
  202.     {
  203.         String strRc = str;
  204.         int nQuestionMarkPos = str.indexOf('?');
  205.         if (nQuestionMarkPos != -1) {
  206.             strRc = str.substring(0, nQuestionMarkPos);
  207.         }
  208.         return strRc;
  209.     }
  210.     
  211.     static String GetNormalizedLocal(String str)
  212.     {
  213.         String local = str;
  214.         // fix up special characters (for netscape)
  215.         for (int i = 0; i < local.length(); i++)
  216.         {
  217.             if (local.charAt(i) > 127)
  218.             {
  219.                 local = local.substring(0, i) + "%" + Integer.toString(local.charAt(i), 16) + local.substring(i + 1, local.length());
  220.             }
  221.         }
  222.         return local;
  223.     }
  224.     
  225.     //To Do: need a utility to convert html<->text
  226.     //Copy from SiteMapParserToContents
  227.     //String fixSpecialCharacters(String value) 
  228.     static String  tuHtmlToText(String value) 
  229.     {
  230.         if (value == null)
  231.             return null;
  232.         
  233.         // TODO: This should be common in SiteMapParser or something
  234.         int i = value.indexOf('&');
  235.         
  236.         if (i < 0) return value;
  237.  
  238.         String strOut = "";
  239.  
  240.         // have to convert & and the like
  241.         while (i > -1 && i < value.length() - 2) {
  242.             strOut += value.substring(0, i);
  243. //    System.out.println("1strOut is now '" + strOut + "'");
  244.             String str = value.substring(i);
  245.             String strEnd = "";
  246.             int j = str.indexOf(';');
  247.             if (j < 0) {
  248.                 strOut += str;
  249. //    System.out.println("2strOut is now '" + strOut + "'");
  250.                 break;    // no termination
  251.             }
  252.             if (j < str.length()-1) {
  253.                 value = str.substring(j+1);
  254.             }
  255.             else {
  256.                 value = "";
  257.             }
  258.             str = str.substring(1, j);
  259. //    System.out.println("value is now '" + value + "'");
  260. //    System.out.println("str is now '" + str + "'");
  261.             // TODO: Should use a hashtable and support more characters
  262.             switch (Character.toUpperCase(str.charAt(0))) 
  263.             {
  264.             case 'A':
  265.                 if (str.equalsIgnoreCase("amp")) {
  266.                     str = "&";
  267.                 }
  268.                 break;
  269.             case 'C':
  270.                 if (str.equalsIgnoreCase("copy")) {
  271.                     str = "(c)";
  272.                 }
  273.                 break;
  274.             case 'G':
  275.                 if (str.equalsIgnoreCase("gt")) {
  276.                     str = ">";
  277.                 }
  278.                 break;
  279.             case 'L':
  280.                 if (str.equalsIgnoreCase("lt")) {
  281.                     str = "<";
  282.                 }
  283.                 break;
  284.             case 'N':
  285.                 if (str.equalsIgnoreCase("nbsp")) {
  286.                     str = " ";
  287.                 }
  288.                 break;
  289.             case 'Q':
  290.                 if (str.equalsIgnoreCase("quot")) {
  291.                     str = "\"";
  292.                 }
  293.                 break;
  294.             case 'R':
  295.                 if (str.equalsIgnoreCase("reg")) {
  296.                     str = "(R)";
  297.                 }
  298.                 break;
  299.             }
  300.             strOut += str;
  301.             i = value.indexOf('&');
  302.             if (i < 0) {
  303.                 strOut += value;
  304. //    System.out.println("3strOut is now '" + strOut + "'");
  305.             }
  306.         }
  307.  
  308. //    System.out.println("4strOut is now '" + strOut + "'");
  309.         return strOut;
  310.     }
  311. }
  312.  
  313.  
  314.  
  315. // Here is a sample show how to use this class
  316. // CshTester.htm
  317. //<HTML>
  318. //<HEAD>
  319. //<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
  320. //</HEAD>
  321. //<BODY>
  322. //
  323. //<P> </P>
  324. //
  325. //
  326. //<!-- Insert HTML here -->
  327. //    <applet
  328. //        code=robohelp/CshTester.class
  329. //        name=CshTester
  330. //        width=500
  331. //        height=500  MAYSCRIPT VIEWASTEXT>
  332. //    <param name=defaulturl value="africa_csh.htm">
  333. //    <param name=left  value=50>
  334. //    <param name=top value=50>
  335. //    <param name=width value=600>
  336. //    <param name=height value=400>
  337. //    </applet>
  338. //
  339. //</BODY>
  340. //</HTML>
  341.  
  342.  
  343. // CshTester.java
  344. //package robohelp;
  345. //
  346. //import java.awt.*;
  347. //import java.applet.*;
  348. //import java.net.*;
  349. //import java.io.*;
  350. //
  351. ///**
  352. // * This class reads PARAM tags from its HTML host page and sets
  353. // * the color and label properties of the applet. Program execution
  354. // * begins with the init() method. 
  355. // */
  356. //public class CshTester extends Applet
  357. //{
  358. //  GridBagLayout gridBagLayout1 = new GridBagLayout();
  359. //  Label label1 = new Label();
  360. //  Label label2 = new Label();
  361. //  Label label3 = new Label();
  362. //  TextField m_edtProject = new TextField();
  363. //  Checkbox m_btnId = new Checkbox();
  364. //  Checkbox m_btnNumber = new Checkbox();
  365. //  Checkbox m_btnRmtURL = new Checkbox();
  366. //  Checkbox m_btnAuto = new Checkbox();
  367. //  CheckboxGroup m_grpId = new CheckboxGroup();
  368. //  TextField m_edtValue = new TextField();
  369. //  Label label4 = new Label();
  370. //  Label label5 = new Label();
  371. //  TextField m_edtLeft = new TextField();
  372. //  Label label6 = new Label();
  373. //  TextField m_edtTop = new TextField();
  374. //  Label label7 = new Label();
  375. //  Label label8 = new Label();
  376. //  TextField m_edtHeight = new TextField();
  377. //  TextField m_edtWidth = new TextField();
  378. //  Label label9 = new Label();
  379. //  Checkbox m_btnLocation = new Checkbox();
  380. //  Checkbox m_btnToolbar = new Checkbox();
  381. //  Checkbox m_btnMenubar = new Checkbox();
  382. //  Checkbox m_btnStatus = new Checkbox();
  383. //  Checkbox m_btnScrollbars = new Checkbox();
  384. //  Checkbox m_btnResizable = new Checkbox();
  385. //  Button m_btnTest = new Button();
  386. //  Label label10 = new Label();
  387. //  TextArea m_areaSyntax = new TextArea();
  388. //    
  389. //    // width, height top, left                        IE
  390. //    // ScreenX, ScreenY, OuterWidth, OuterHeight    NS
  391. //    
  392. //    private String m_strSyntax;
  393. //
  394. //    public void init()
  395. //    {
  396. //        label1.setText("Test applet for WebHelp Context Sensitive Help for java applets");
  397. //        this.setLayout(gridBagLayout1);
  398. //        label3.setText("Help project csh file(<project name>_chs.htm):");
  399. //        m_btnId.setName("m_btnId");
  400. //        m_btnId.setCheckboxGroup(m_grpId);
  401. //        m_btnId.setLabel("TopicId");
  402. //        m_btnNumber.setName("m_btnNumber");
  403. //        m_btnNumber.setCheckboxGroup(m_grpId);
  404. //        m_btnNumber.setLabel("TopicNumber");
  405. //        m_btnRmtURL.setName("m_btnRmtURL");
  406. //        m_btnRmtURL.setCheckboxGroup(m_grpId);
  407. //        m_btnRmtURL.setLabel("Remote URL");
  408. //        m_btnAuto.setName("m_btnAuto");
  409. //        m_btnAuto.setCheckboxGroup(m_grpId);
  410. //        m_btnAuto.setLabel("Auto Detect");
  411. //        m_btnAuto.setState(true);
  412. //        m_edtValue.setName("m_edtValue");
  413. //        m_edtValue.setColumns(60);
  414. //        label4.setText("Topic window position:");
  415. //        label5.setText("Left:");
  416. //        m_edtLeft.setName("m_edtLeft");
  417. //        m_edtLeft.setColumns(4);
  418. //        label6.setText("Top:");
  419. //        m_edtTop.setName("m_edtTop");
  420. //        m_edtTop.setColumns(4);
  421. //        label7.setText("Width:");
  422. //        label8.setText("Height:");
  423. //        m_edtHeight.setName("m_edtHeight");
  424. //        m_edtHeight.setColumns(4);
  425. //        m_edtWidth.setName("m_edtWidth");
  426. //        m_edtWidth.setColumns(4);
  427. //        label9.setText("Topic window options:");
  428. //        m_btnLocation.setName("m_btnLocation");
  429. //        m_btnLocation.setLabel("Location");
  430. //        m_btnToolbar.setName("m_btnToolbar");
  431. //        m_btnToolbar.setLabel("Toolbar");
  432. //        m_btnMenubar.setName("m_btnMenubar");
  433. //        m_btnMenubar.setLabel("Menubar");
  434. //        m_btnStatus.setName("m_btnStatus");
  435. //        m_btnStatus.setLabel("Status");
  436. //        m_btnScrollbars.setName("m_btnScrollbars");
  437. //        m_btnScrollbars.setLabel("Scrollbars");
  438. //        m_btnResizable.setName("m_btnResizable");
  439. //        m_btnResizable.setLabel("Resizable");
  440. //                 
  441. //        m_btnResizable.setState(true);
  442. //        m_btnScrollbars.setState(true);
  443. //
  444. //        m_btnTest.setName("m_btnTest");
  445. //        m_btnTest.setLabel("Test Help");
  446. //        label10.setText("Syntax to add to your java applet code:");
  447. //        m_areaSyntax.setName("m_areaSyntax");
  448. //        m_areaSyntax.setColumns(80);
  449. //        m_areaSyntax.setEditable(false);
  450. //        
  451. //        m_edtProject.setName("");
  452. //        m_edtProject.setColumns(60);
  453. //
  454. //        this.add(label1, GetGridBagConstraints(0, 0, 6, 1, 0.0, 0.0
  455. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 6, 0));
  456. //        this.add(label2, GetGridBagConstraints(0, 1, 1, 1, 0.0, 0.0
  457. //                ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 37), 0, 0));
  458. //        this.add(label3, GetGridBagConstraints(1, 2, 5, 1, 0.0, 0.0
  459. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  460. //        this.add(m_edtProject, GetGridBagConstraints(1, 3, 5, 1, 0.0, 0.0
  461. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  462. //        this.add(m_btnId, GetGridBagConstraints(1, 4, 1, 1, 0.0, 0.0
  463. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  464. //        this.add(m_btnNumber, GetGridBagConstraints(2, 4, 1, 1, 0.0, 0.0
  465. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  466. //        this.add(m_btnRmtURL, GetGridBagConstraints(3, 4, 1, 1, 0.0, 0.0
  467. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  468. //        this.add(m_btnAuto, GetGridBagConstraints(4, 4, 1, 1, 0.0, 0.0
  469. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  470. //        this.add(m_edtValue, GetGridBagConstraints(1, 5, 5, 1, 0.0, 0.0
  471. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  472. //        this.add(label4, GetGridBagConstraints(1, 6, 2, 1, 0.0, 0.0
  473. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  474. //        this.add(label6, GetGridBagConstraints(4, 7, 1, 1, 0.0, 0.0
  475. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  476. //        this.add(m_edtTop, GetGridBagConstraints(5, 7, 1, 1, 0.0, 0.0
  477. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  478. //        this.add(m_edtHeight, GetGridBagConstraints(5, 8, 1, 1, 0.0, 0.0
  479. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  480. //        this.add(label8, GetGridBagConstraints(4, 8, 1, 1, 0.0, 0.0
  481. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  482. //        this.add(m_edtLeft, GetGridBagConstraints(3, 7, 1, 1, 0.0, 0.0
  483. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  484. //        this.add(m_edtWidth, GetGridBagConstraints(3, 8, 1, 1, 0.0, 0.0
  485. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  486. //        this.add(label5, GetGridBagConstraints(2, 7, 1, 1, 0.0, 0.0
  487. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  488. //        this.add(label7, GetGridBagConstraints(2, 8, 1, 1, 0.0, 0.0
  489. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  490. //        this.add(label9, GetGridBagConstraints(1, 9, 2, 1, 0.0, 0.0
  491. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  492. //        this.add(m_btnLocation, GetGridBagConstraints(2, 10, 1, 1, 0.0, 0.0
  493. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  494. //        this.add(m_btnToolbar, GetGridBagConstraints(3, 10, 1, 1, 0.0, 0.0
  495. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  496. //        this.add(m_btnMenubar, GetGridBagConstraints(4, 10, 1, 1, 0.0, 0.0
  497. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  498. //        this.add(m_btnStatus, GetGridBagConstraints(2, 11, 1, 1, 0.0, 0.0
  499. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  500. //        this.add(m_btnScrollbars, GetGridBagConstraints(3, 11, 1, 1, 0.0, 0.0
  501. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  502. //        this.add(m_btnResizable, GetGridBagConstraints(4, 11, 1, 1, 0.0, 0.0
  503. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  504. //        this.add(m_btnTest, GetGridBagConstraints(3, 12, 1, 1, 0.0, 0.0
  505. //                ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  506. //        this.add(label10, GetGridBagConstraints(0, 13, 6, 1, 0.0, 0.0
  507. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  508. //        this.add(m_areaSyntax, GetGridBagConstraints(0, 14, 6, 1, 0.0, 0.0
  509. //                ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 60, 0));
  510. //
  511. //        String strDefaultURL = getParameter("defaulturl");
  512. //        if (strDefaultURL != null)
  513. //              m_edtProject.setText(strDefaultURL);
  514. //
  515. //        String strLeft = getParameter("left");
  516. //        try {
  517. //            if (strLeft != null && Integer.parseInt(strLeft, 10)>=0 )
  518. //                m_edtLeft.setText(strLeft);
  519. //            else
  520. //                m_edtLeft.setText("0");
  521. //        }
  522. //        catch (NumberFormatException e) {
  523. //            m_edtLeft.setText("0");
  524. //        }
  525. //
  526. //        String strTop = getParameter("top");
  527. //        try {
  528. //            if (strTop != null && Integer.parseInt(strTop, 10)>=0)
  529. //                m_edtTop.setText(strTop);
  530. //            else
  531. //                m_edtTop.setText("0");
  532. //        }
  533. //        catch (NumberFormatException e) {
  534. //            m_edtTop.setText("0");
  535. //        }
  536. //
  537. //        String strWidth = getParameter("width");
  538. //        try {
  539. //            if (strWidth != null && Integer.parseInt(strWidth, 10)>=0)
  540. //                m_edtWidth.setText(strWidth);
  541. //            else
  542. //                m_edtWidth.setText("0");
  543. //        }
  544. //        catch (NumberFormatException e) {
  545. //            m_edtWidth.setText("0");
  546. //        }
  547. //
  548. //        String strHeight = getParameter("height");
  549. //        try {
  550. //            if (strHeight != null && Integer.parseInt(strHeight, 10)>=0)
  551. //                m_edtHeight.setText(strHeight);
  552. //            else
  553. //                m_edtHeight.setText("0");
  554. //        }
  555. //        catch (NumberFormatException e) {
  556. //            m_edtHeight.setText("0");
  557. //        }
  558. //    }
  559. //    
  560. //    public boolean action(Event e, Object o)
  561. //    {
  562. //        if (e.target != m_btnTest) return true;
  563. //        String strURL = m_edtProject.getText();
  564. //        
  565. //        String strTopic = "";
  566. //        if (m_grpId.getSelectedCheckbox() == m_btnAuto) {
  567. //            strTopic = m_edtValue.getText();
  568. //        }
  569. //        else if (m_grpId.getSelectedCheckbox() == m_btnId) {
  570. //            strTopic = "TopicId=" + m_edtValue.getText();
  571. //        }
  572. //        else if (m_grpId.getSelectedCheckbox() == m_btnNumber) {
  573. //            strTopic = "TopicNumber=" + m_edtValue.getText();
  574. //        }
  575. //        else if (m_grpId.getSelectedCheckbox() == m_btnRmtURL) {
  576. //            strTopic = "RemoteURL=" + m_edtValue.getText();
  577. //        }
  578. //        
  579. //        String strWindowOptions = "";
  580. //        
  581. //        int left, top, width, height, flag=0;
  582. //        try {
  583. //            left = Integer.parseInt(m_edtLeft.getText(), 10);
  584. //        }
  585. //        catch (Exception x) {
  586. //            left = 0;
  587. //        }
  588. //        try {
  589. //            top = Integer.parseInt(m_edtTop.getText(), 10);
  590. //        }
  591. //        catch (Exception y) {
  592. //            top = 0;
  593. //        }
  594. //
  595. //        try {
  596. //            width = Integer.parseInt(m_edtWidth.getText(), 10);
  597. //        }
  598. //        catch (Exception z) {
  599. //            width = 0;
  600. //        }
  601. //        try {
  602. //            height = Integer.parseInt(m_edtHeight.getText(), 10);
  603. //        }
  604. //        catch (Exception w) {
  605. //            height = 0;
  606. //        }
  607. //
  608. //        String strFlag = "";
  609. //        if (m_btnLocation.getState()) {
  610. //            flag |= ShowWebHelp.WOF_LOCATION;
  611. //            strFlag += "| ShowWebHelp.WOF_LOCATION ";
  612. //        }
  613. //            
  614. //        if (m_btnMenubar.getState()) {
  615. //            flag |= ShowWebHelp.WOF_MENUBAR;
  616. //            strFlag += "| ShowWebHelp.WOF_MENUBAR ";
  617. //        }
  618. //        
  619. //        if (m_btnResizable.getState()) {
  620. //            flag |= ShowWebHelp.WOF_RESIZABLE;
  621. //            strFlag += "| ShowWebHelp.WOF_RESIZABLE ";
  622. //        }
  623. //        
  624. //        if (m_btnToolbar.getState()) {
  625. //            flag |= ShowWebHelp.WOF_TOOLBAR;
  626. //            strFlag += "| ShowWebHelp.WOF_TOOLBAR ";
  627. //        }
  628. //        
  629. //        if (m_btnStatus.getState()) {
  630. //            flag |= ShowWebHelp.WOF_STATUS;
  631. //            strFlag += "| ShowWebHelp.WOF_STATUS ";
  632. //        }
  633. //        
  634. //        if (m_btnScrollbars.getState()) {
  635. //            flag |= ShowWebHelp.WOF_SCROLLBARS;
  636. //            strFlag += "| ShowWebHelp.WOF_SCROLLBARS ";
  637. //        }
  638. //    
  639. //        if (strFlag.length() == 0) {
  640. //            strFlag = "0";
  641. //        }
  642. //        else {
  643. //            strFlag = strFlag.substring(2, strFlag.length()-1);
  644. //        }
  645. //        
  646. //        m_strSyntax  = "import robohelp.ShowWebHelp;\r\n\r\n";
  647. //        m_strSyntax += "    cshURL   = \"" + strURL + "\";\r\n";
  648. //        m_strSyntax += "    topic    = \"" + strTopic + "\";\r\n";
  649. //        m_strSyntax += "    options     = " + strFlag + ";\r\n";
  650. //        m_strSyntax += "    ShowWebHelp.context(cshURL, topic, " + left + ","
  651. //            + top + "," + width + "," + height + ", options, applet);\r\n";
  652. //
  653. //        m_areaSyntax.setText(m_strSyntax);
  654. //        
  655. //        if (!ShowWebHelp.context(strURL, strTopic, left, top, width, height, flag, this)) {
  656. //            m_areaSyntax.setText("Error: Unable to find the topic, please check the URL");
  657. //            return false;
  658. //        }
  659. //        else
  660. //            return true;
  661. //
  662. //    }
  663. //    
  664. //    GridBagConstraints GetGridBagConstraints(int gridx, int gridy,
  665. //                            int gridwidth, int gridheight,
  666. //                            double weightx, double weighty,
  667. //                            int anchor, int fill,
  668. //                            Insets insets, int ipadx, int ipady) {
  669. //        GridBagConstraints gbc = new GridBagConstraints();
  670. //        
  671. //        gbc.gridx = gridx;
  672. //        gbc.gridy = gridy;
  673. //        gbc.gridwidth = gridwidth;
  674. //        gbc.gridheight = gridheight;
  675. //        gbc.fill = fill;
  676. //        gbc.ipadx = ipadx;
  677. //        gbc.ipady = ipady;
  678. //        gbc.insets = insets;
  679. //        gbc.anchor  = anchor;
  680. //        gbc.weightx = weightx;
  681. //        gbc.weighty = weighty;
  682. //        return gbc;
  683. //    }    
  684. //}
  685.